import request, { download } from '@/utils/request'

/**
 * ${table.tableComment} Api
 *
 * @author ${table.author}
 * @date ${date}
 */
export default {

    /**
     * 分页查询
     * @param query 查询参数
     */
    page: (query: any) => {
        return request.get('<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}/page',{params: query})
    },

    /**
     * 查询列表
     * @param query 查询参数
     */
    list: (query: any) => {
        return request.get('<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}/list',{params: query})
    },

    /**
     * 查询详细
     * @param query 查询参数
     */
    getById: (id: string) => {
        return request.get(`<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}/<#noparse>${id}</#noparse>`)
    },

    /**
     * 新增
     * @param data 新增数据
     */
    add: (data: any) => {
        return request.post('<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}',data)
    },

    /**
     * 修改
     * @param data 修改数据
     */
    update: (data: any) => {
        return request.put('<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}',data)
    },

    /**
     * 删除
     * @param ids 删除Ids
     */
    delete: (ids: any) => {
        return request.delete(`<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}/<#noparse>${ids}</#noparse>`)
    },

    /**
     * 导出Excel
     * @param filename Excel文件名称
     * @param query 查询参数
     */
	download: (query: any, filename: string) => {
		download("<#if table.contextPath??>${table.contextPath}/</#if><#if table.moduleName?? && table.moduleName != "">${table.moduleName}/</#if>${table.path}/export", { ...query }, `<#noparse>${filename}</#noparse>.xlsx`,{});
	}

}